package com.example.controller;


import com.example.entity.TbSpecification;
import com.example.service.TbSpecificationService;
import com.example.vo.TbSpecificationVO;
import com.example.utils.PageResult;
import com.example.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/specification")
 @CrossOrigin            // 解决跨域问题
public class TbSpecificationController {

	@Autowired
	private TbSpecificationService tbSpecificationService;
	@PostMapping("/search")
	public PageResult<TbSpecification> search(@RequestParam("page") Integer page,
											  @RequestParam("pageSize") Integer pageSize,
											  @RequestBody(required = false) TbSpecificationVO tbSpecificationVO){
		return tbSpecificationService.search(page,pageSize,tbSpecificationVO);
	}
	@PostMapping("/save")
	public R save(@RequestBody TbSpecification tbSpecification){
		return tbSpecificationService.save(tbSpecification) ? R.ok().message("添加成功！") : R.error().message("添加失败！");
	}
}